<?php
    include('checkAdminAccess.php');
    $iniVars = parse_ini_file('../../config.ini',TRUE);
    include('../classes/adodb5/adodb.inc.php');
    include('../classes/class.upload.php');
    include('../function/db.func.php');
    
    $action = $_POST['action'];
    
    if($action=='msg')
    {
        $sql = 'UPDATE rate_data SET rd_value="'.addslashes($_POST['editor1']).'" WHERE rd_id=1';
        $result = $db->Execute($sql);
        if($result)
        {
            $error = FALSE;
            $msg = "<br />แก้ไขข้อมูลเรียบร้อยแล้ว";
        }
        else
        {
            $error = TRUE;
            $msg = "<br />ไม่สามารถแก้ไขข้อมูลได้ กรุณาลองใหม่อีกครั้ง.";
        }
        
        
         if($error)
        {
            echo <<<js
            <script src="{$iniVars['Locations']['siteurl']}js/jquery.js" type="text/javascript"></script>
            <script type="text/javascript">
                $(".msg_submit_indicator", top.document).css('display','none');
                $("#msg_error_msg", top.document).html('{$msg}');
                $("#msg_error_msg", top.document).css('display','block');
                setInterval("top.location='../index.php?page=rate&part=rate1';",3000);
            </script>
js;
        }
        else
        {
            echo <<<js
            <script src="{$iniVars['Locations']['siteurl']}js/jquery.js" type="text/javascript"></script>
            <script type="text/javascript">
                $(".msg_submit_indicator", top.document).css('display','none');
                $("#msg_success_msg", top.document).html('{$msg}');
                $("#msg_success_msg", top.document).css('display','block');
                setInterval("top.location='../index.php?page=rate&part=rate1';",3000);
            </script>
js;
        }
    }
?>